<template>
  <div class="platform_order_import_recode">
    <c-title :hide="false" text="转换记录"></c-title>
    <div class="list">
      <div class="lis" v-for="(item,i) in list" :key="i">
        <div class="line">
          <div class="left sn">订单号：{{item.order_sn}}</div>
          <div class="right typeIN">{{item.has_one_platform&&item.has_one_platform.name}}</div>
        </div>
        <div class="line line_b">
          <div class="left time">{{ item.match_time }}</div>
          <div class="right more" @click="popup_open(item)">
            查看奖励
            <i class="iconfont icon-icon_more11"></i>
          </div>
        </div>
      </div>
    </div>
    <van-popup v-model="show" style="background: transparent;">
      <div class="popupBox" v-if="popup_list&&popup_list.length!==0">
        <div class="title">获得以下奖励</div>
        <div class="reward_list">
          <div class="reward_lis" v-for="(item, ind) in popup_list" :key="ind">
            <div class="imgBox">
              <img :src="item.icon" alt="" />
            </div>
            <div class="rewardTxt"><span class="txt">+{{ item.value }}</span>{{item.name}}</div>
            <div class="rewardBtn" @click="goto(item.code)">去查看</div>
          </div>
        </div>
      </div>
      <i class="iconfont icon-adsystem_icon_cancle" @click="show = false"></i>
    </van-popup>
  </div>
</template>
<script>
import { scrollMixin } from '../../utils/mixin';
export default {
  mixins:[scrollMixin],
  data() {
    return {
      show: false,
      list:[],
      page:1,
      total_page:1,
      popup_list:[],
      isLoadMore:true,

    };
  },
  activated(){
    this.show = false;
    this.isLoadMore = true;
    this.record();
  },
  methods: {
    goto(code){
      if(code == 'point'){
        this.$router.push(this.fun.getUrl('integral_v2'));
      }else if(code == 'love'){
        this.$router.push(this.fun.getUrl('love_index'));
      }else if(code == 'balance'){
        this.$router.push(this.fun.getUrl('balance'));
      }else if(code == 'integral'){
        this.$router.push(this.fun.getUrl('Integral_love'));
      }
    },
    getMoreData(){
      this.isLoadMore = false;
      if(this.page>=this.total_page){
        return;
      }
      let page = this.page + 1;
      this.record(page);
    },
    popup_open(data){
      $http.get("plugin.platform-order-import.frontend.convert-record.show-reward", {order_id:data.order_id}, '').then(({ result, msg, data }) => {
        if (result !== 1) {
          return this.$toast(msg);
        }
        this.popup_list = data;
        this.show = true;
      })
    },
    record(page=1) {
      $http.get("plugin.platform-order-import.frontend.convert-record.index", {page}, '').then(({ result, msg, data }) => {
        if (result !== 1) {
          return this.$toast(msg);
        }
        this.list = page==1? data.data:this.list.concat(data.data);
        this.page = data.current_page;
        this.total_page = data.last_page;
      })
    },
  }
};
</script>
<style lang="scss" scoped>
.list {
  margin: 0.63rem 0.75rem;

  .lis {
    border-radius: 0.5rem;
    background: #ffffff;
    margin-bottom: 0.63rem;
    padding: 0.94rem 0.75rem;
    box-sizing: border-box;

    .line_b {
      margin-top: 0.59rem;
    }

    .line {
      display: flex;
      justify-content: space-between;
      align-items: center;

      .left {
        flex: 1;
      }

      .right {
        flex-shrink: 0;
      }

      .time {
        font-size: 0.81rem;
        color: #6e6e79;
        text-align: left;
      }

      .more {
        display: flex;
        align-items: center;
        color: #6e6e79;

        .icon-icon_more11 {
          color: #aaaab3;
          font-size: 0.8rem;
        }
      }

      .sn {
        color: #00001c;
        font-weight: 500;
        text-align: left;
        font-size: 0.81rem;
      }

      .typeIN {
        color: #f15353;
        font-size: 0.88rem;
        font-weight: 500;
      }
    }
  }

  .lis:last-child {
    margin-bottom: 0;
  }
}

.popupBox {
  width: 17.5rem;
  background: #ffffff;
  border-radius: 1.13rem;
  margin-bottom: 1.56rem;
  padding: 1.19rem 0.94rem;
  box-sizing: border-box;
  overflow: hidden;
  box-sizing: border-box;

  .title {
    font-weight: bold;
    font-size: 0.88rem;
    text-align: left;
    margin-bottom: 0.78rem;
  }

  .reward_list {
    .reward_lis {
      margin-bottom: 0.63rem;
      display: flex;
      align-items: center;
      justify-content: space-between;

      .imgBox {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 50%;
        flex-shrink: 0;

        img {
          width: 2.5rem;
          height: 2.5rem;
          border-radius: 50%;
        }
      }

      .rewardTxt {
        flex: 1;
        margin-left: 0.5rem;
        font-size: 0.88rem;
        text-align: left;
        font-weight: bold;

        .txt {
          color: #f15353;
        }
      }

      .rewardBtn {
        width: 3.63rem;
        height: 1.75rem;
        background: #f15353;
        border-radius: 1.88rem;
        color: #ffffff;
        text-align: center;
        line-height: 1.75rem;
      }
    }

    .reward_lis:last-child {
      margin-bottom: 0;
    }
  }
}

.icon-adsystem_icon_cancle {
  font-size: 2rem;
  color: #ffffff;
}
</style>
